package com.hooda.utils;

import java.sql.SQLException;

/**
 * @author zhangzp
 * @version 1.0, 2021/9/9
 */
public class TransactionManager {

    private static TransactionManager transactionManager = new TransactionManager();

    public static TransactionManager getInstance() {
        return transactionManager;
    }

    private TransactionManager() {

    }

    public void beginTransaction() throws SQLException {
        ConnectionUtils.getInstance().getCurrentThreadConnection().setAutoCommit(false);
    }

    public void commit() throws SQLException {
        ConnectionUtils.getInstance().getCurrentThreadConnection().commit();
    }

    public void rollback() throws SQLException {
        ConnectionUtils.getInstance().getCurrentThreadConnection().rollback();
    }
}
